<?php
namespace Home\Controller;
use Think\Controller;
class MeishisController extends BaseController {

public function meishis(){
    $this->display();
}

public function fenxiang(){
    $meishis = M('meishis');
    $qrcodenum=$meishis->count();
    $Page = new \Think\Page($qrcodenum,2);
    $Page->setConfig('header', '共<b>%TOTAL_ROW%</b>条记录&nbsp;&nbsp;
每页<b>2</b>条&nbsp;&nbsp;第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页');
    $Page->setConfig('prev','上一页');
    $Page->setConfig('next','下一页');
    $Page->setConfig('last','末页');
    $Page->setConfig('first','首页');
    $Page->setConfig('theme',' %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
    $this->pageNav=$Page->show();//在页面{pageNav}
    //$this->link=$Page->show();
    $this->qrcodeList=$meishis->limit($Page->firstRow,2)->order('id desc')->select();
    $this->display();
}

public function domeishis(){
    $meishis=D("meishis");
    if($meishis->create()){
        if($meishis->create()){
            if($_FILES['file']['error']==0){
                $logoinfo = $this->Upload1();
                $pname=$logoinfo['file']['savename'];
            }else{
                $pname = "default.jpg";
            }
        }
        $meishis->picture=$pname;
        if(false!=$meishis->add()){
            //$this->crop1($pname);
            $this->success('发布成功!','fenxiang');
        }else{$this->error('数据错误');}
    } else{
        $this->error($meishis->getError());
    }
}

    public function upload1(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize  = 3145728 ;// 设置附件上传大小
        $upload->exts     = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath = "./Public/Uploads/meishisphoto/"; // 设置附件上传根目录
        $upload->savePath = ""; // 设置附件上传（子）目录
        $upload->autoSub = false;
        $upload->saveName = 'time';
        //$upload->savePath = ""
        $info = $upload->upload();  // 上传文件
        if(!$info) {
            $this->error($upload->getError());
        } else {
            return $info;
            //$this->success('上传成功');
        }
   } 

}







